"""
Enumeration types for parameter-efficient fine-tuning (PEFT) methods.

This module centralizes all enum definitions used across PEFT interfaces
to ensure consistency and avoid circular imports.
"""

from enum import Enum


class PEFTMethod(Enum):
    """
    Enumeration of supported Parameter-Efficient Fine-Tuning methods.

    These methods allow for efficient adaptation of pre-trained models with
    minimal parameter updates.
    """

    LORA = "lora"  # Low-Rank Adaptation
    BYPASS_LORA = "bypass_lora"  # Bypass Low-Rank Adaptation
    PREFIX_TUNING = "prefix_tuning"  # Prefix-based tuning
    PROMPT_TUNING = "prompt_tuning"  # Learnable prompt tuning
    P_TUNING = "p_tuning"  # P-Tuning approach
    ADAPTER = "adapter"  # Standard adapter modules
    IA3 = "ia3"  # Infused Adapter by Inhibiting and Amplifying Inner Activations


class PromptPosition(Enum):
    """
    Enumeration of positions where prompts can be inserted.

    Different prompt methods insert tokens at different positions:
    - PREPEND: Add prompts before the input sequence
    - APPEND: Add prompts after the input sequence
    - DEEP: Add prompts at multiple positions throughout the network
    """

    PREPEND = "prepend"  # Add prompts at the beginning of the sequence
    APPEND = "append"  # Add prompts at the end of the sequence
    DEEP = "deep"  # Add prompts at various positions throughout the network


class AdapterType(Enum):
    """
    Enumeration of adapter types for parameter-efficient fine-tuning.

    Different types of adapters interact with the backbone differently:
    - PRE_BACKBONE: Adapters that modify the backbone itself before forward pass (e.g., LoRA)
    - POST_BACKBONE: Adapters that process the backbone's output (e.g., Prompt-based methods)
    """

    PRE_BACKBONE = (
        "pre_backbone"  # Adapters that modify the backbone itself (e.g., LoRA)
    )
    POST_BACKBONE = (
        "post_backbone"  # Adapters that process backbone outputs (e.g., Prompts)
    )


class HookType(Enum):
    """
    Enumeration of hook types.

    These types determine how hooks interact with their target modules:
    - FORWARD_PRE: Executes before the module's forward method
    - FORWARD_POST: Executes after the module's forward method
    - FORWARD_REPLACE: Completely replaces the module's forward method
    - BACKWARD_PRE: Executes before the module's backward method
    - BACKWARD_POST: Executes after the module's backward method
    """

    FORWARD_PRE = "forward_pre"
    FORWARD_POST = "forward_post"
    FORWARD_REPLACE = "forward_replace"
    BACKWARD_PRE = "backward_pre"
    BACKWARD_POST = "backward_post"


class HookState(Enum):
    """
    Enumeration of hook states.

    Provides a more detailed representation of a hook's lifecycle:
    - INITIALIZED: Hook created but not yet attached
    - ACTIVE: Hook is currently attached and active
    - DETACHED: Hook was previously active but now detached
    """

    INITIALIZED = "initialized"
    ACTIVE = "active"
    DETACHED = "detached"
